//
//  SerchTableViewController.m
//  壳牌喜力促销积分商城
//
//  Created by xrd on 15/3/21.
//  Copyright (c) 2015年 xrd. All rights reserved.
//

#import "SerchTableViewController.h"
#import "ShopingViewController.h"
@interface SerchTableViewController ()



//@property(nonatomic,strong)UIView *titleView;



//
//@property(nonatomic,strong)UILabel *nickNameLabel;
//@property(nonatomic,strong)NSArray *dataArray;
//@property(nonatomic,strong)NSArray *imageArray;
@end

@implementation SerchTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.tile = @"搜索界面";
    
    CGFloat W = self.view.bounds.size.width;
    CGFloat H  = 50;
    UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, W, H)];
    titleView .backgroundColor = [UIColor redColor];
    [self.view addSubview:titleView];
    
    UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    
    
    
    
    if (self.searchFristCount) {
        // 弹出提示框
        [self remindCount];
    }
   
}
- (void)remindCount
{
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, 44)];
    titleLabel.backgroundColor = [UIColor orangeColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    if (self.searchTwoCount) {
        titleLabel.text = [NSString stringWithFormat:@"搜索 %@ - %@ ", self.searchFristCount, self.searchTwoCount];
    }else{
        titleLabel.text = [NSString stringWithFormat:@"搜索 %@ ", self.searchFristCount];
    }
    // 5.添加到导航控制器的view
    //    [self.navigationController.view addSubview:label];
    [self.navigationController.view insertSubview:titleLabel belowSubview:self.navigationController.navigationBar];
    
    // 6.动画
    CGFloat duration = 0.75;
    //    label.alpha = 0.0;
    [UIView animateWithDuration:duration animations:^{
        // 往下移动一个label的高度
        titleLabel.transform = CGAffineTransformMakeTranslation(0, titleLabel.bounds.size.height);
        //
        
        
        //        label.alpha = 1.0;
    } completion:^(BOOL finished) { // 向下移动完毕
        
        // 延迟delay秒后，再执行动画
        //        CGFloat delay = 1.0;
        CGFloat delay = 1.0;
        
        [UIView animateWithDuration:duration delay:delay options:UIViewAnimationOptionCurveEaseInOut animations:^{
            
            // 恢复到原来的位置
            titleLabel.transform = CGAffineTransformIdentity;
            //            label.alpha = 0.0;
            
        } completion:^(BOOL finished) {
            
            // 删除控件
            [titleLabel removeFromSuperview];
        }];
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];






}

#pragma mark - Table view data source

//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//#warning Potentially incomplete method implementation.
//    // Return the number of sections.
//    return 0;
//}
//
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 10;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //1.创建cell
    UITableViewCell *cell = [[UITableViewCell alloc ]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    
    //    2.给cell 进行传递数据模式
//    cell.detailMode = self.detailModes[indexPath.row];
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/


#pragma mark - Table view delegate

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here, for example:
    // Create the next view controller.
    ShopingViewController *ShopingViewController = [[[NSBundle mainBundle]loadNibNamed:@"ShopingViewController" owner:nil options:nil]lastObject];
    
    
    
    // Pass the selected object to the new view controller.
    
    // Push the view controller.
    [self.navigationController pushViewController:ShopingViewController animated:YES];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
